package org.example.demo.service.userService.impl;

import org.example.demo.service.userService.UserCenterService;
import org.example.mbg.mapper.FavoriteMapper;
import org.example.mbg.mapper.UserMapper;
import org.example.mbg.model.Favorite;
import org.example.mbg.model.FavoriteExample;
import org.example.mbg.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;

@Service
public class UserCenterServiceImpl implements UserCenterService {
    @Autowired
    UserMapper userMapper;

    @Autowired
    private FavoriteMapper favoriteMapper;

    @Override
    public BigDecimal getBalance(Long user_id) {
        User user = userMapper.selectByPrimaryKey(user_id);
        System.out.println(user.getBalance());
        return user.getBalance();
    }

    @Override
    public List<Favorite> getFavs(Long userId) {
        FavoriteExample favoriteExample = new FavoriteExample();
        favoriteExample.createCriteria().andUserIdEqualTo(userId);
        return favoriteMapper.selectByExample(favoriteExample);
    }

}
